package com.example.com.transcribeeditpublish.popuWindow;

import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

import com.example.com.transcribeeditpublish.R;
import com.example.com.transcribeeditpublish.activity.VideoEditActivity;
import com.example.com.transcribeeditpublish.views.RangeSlider;

public class CutMusicPpWindow extends PopupWindow {
    private final VideoEditActivity activity;

    public CutMusicPpWindow(VideoEditActivity videoEditActivity, RangeSlider.OnRangeChangeListener listener) {
        this.activity = videoEditActivity;
        View view = LayoutInflater.from(activity).inflate(R.layout.popuwindow_cut_music, null, false);
        ((RangeSlider) view.findViewById(R.id.bgm_range_slider)).setRangeChangeListener(listener);
        setContentView(view);
        //适配虚拟键
        this.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        //设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
        this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
        //设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x00000000); //android:background="#30000000"
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);
    }

    public void show(VideoEditActivity videoEditActivity) {
        this.showAtLocation(videoEditActivity.getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
    }
}
